package com.sfac.controller;

import com.sfac.service.CountryService;
import com.sfac.test.Country;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * CountryController
 */
@RestController
@RequestMapping("/api/test")
public class CountryController {

	@Autowired
	private CountryService countryService;

	/**
	 * 127.0.0.1/api/country/522 ---- get
	 */
	@GetMapping(value = "/country/{countryId}")
	public Country getCountryByCountryId(@PathVariable int countryId) {
		return countryService.getCountryByCountryId(countryId);
	}

	/**
	 * 127.0.0.1/api/country?countryName=China ---- get
	 */
	@GetMapping(value = "/country")
	public Country getCountryByCountryName(@RequestParam String countryName) {
		return countryService.getCountryByCountryName(countryName);
	}
}
